package com.wans.product.controller;

import com.wans.product.bean.Product;
import com.wans.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class ProductController {

    @Autowired
    private ServletWebServerApplicationContext webServerApplicationContext;
    @Autowired
    private ProductService productService;

    @GetMapping("/product/getProduct/{id}")
    public Product getProduct(@PathVariable Long id) {
        System.out.println("当前服务端口 ：" + webServerApplicationContext.getWebServer().getPort());
        return productService.getProduct(id);
    }


}
